package classification;

import model.Classifier;
import model.MoveChooser;
import model.Position;

import java.util.List;

/**
 * @author Alex Vikharev vikharev@yandex-team.ru
 *         created 27.02.12
 */
public class ClassifierMoveChooser implements MoveChooser {
    private final Classifier classifier;

    public ClassifierMoveChooser(final Classifier classifier) {
        this.classifier = classifier;
    }

    @Override
    public Position choose(final List<Position> possibleMoves) {
        double max = Double.NEGATIVE_INFINITY;
        Position result = null;
        for (Position possibleMove : possibleMoves) {
            final double score = classifier.classify(possibleMove);
            if (score >= max) {
                max = score;
                result = possibleMove;
            }
        }
        return result;
    }
}
